/*
 * Desain by Sugik Puja Kusuma, S.Kom
 * email   : sugik@do-event.com
 * website : http://www.sugik.do-event.com
 * ===============================================================
 *      Semua sorce dalam program ini dibawah license [GPL]
 *      Silakan Untuk mengembangkan dan memperbanyak source ini
 *      Dengan tidak menghilangkan nama pembuat
 * ===============================================================
 */
package mbahsomo.doevent.loundry.views;

import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.SWT;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;

public class MainMenu {
	protected Shell shell;
	private Menu mnBar;
	private MenuItem mnSystem, mnMaster, mnTransaksi, mnLaporan;
	private Menu menuSystem, menuMaster, menuTransaksi, menuLaporan;
	private MenuItem mnLogin, mnLogOut, mnSystemSp, mnExit;
	private MenuItem mnBarang;
	private MenuItem mnPencucian;
	private Display display;
	
	public MainMenu(){		
		display = Display.getDefault();
		setKomponent();
		//center the dialog screen to the monitor
		Monitor primary = display.getPrimaryMonitor ();
		Rectangle bounds = primary.getBounds ();
		Rectangle rect = shell.getBounds ();
		int x = bounds.x + (bounds.width - rect.width) / 2;
		int y = bounds.y + (bounds.height - rect.height) / 2;
		shell.setLocation (x, y);			
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}
	
	private void setKomponent(){
		shell = new Shell();
		shell.setSize(746, 508);
		shell.setText("DoEvent-L");
		shell.setLayout(new FillLayout(SWT.HORIZONTAL));
		
		mnBar = new Menu(shell, SWT.BAR);
		
		mnSystem = new MenuItem(mnBar, SWT.CASCADE);
		mnSystem.setText("&System");		
		menuSystem = new Menu(shell, SWT.DROP_DOWN);
		mnSystem.setMenu(menuSystem);		
		mnLogin = new MenuItem(menuSystem, SWT.PUSH);
		mnLogin.setText("Login"); 		
		mnLogOut = new MenuItem(menuSystem, SWT.PUSH);
		mnLogOut.setText("Log Out");
		mnSystemSp = new MenuItem(menuSystem, SWT.SEPARATOR);
		mnExit = new MenuItem(menuSystem, SWT.PUSH);
		mnExit.setText("Exit");
		
		mnMaster = new MenuItem(mnBar, SWT.CASCADE);
		mnMaster.setText("&Master");
		menuMaster = new Menu(shell, SWT.DROP_DOWN);
		mnMaster.setMenu(menuMaster);
		mnBarang = new MenuItem(menuMaster, SWT.PUSH);
		mnBarang.setText("Barang");
		
		mnTransaksi = new MenuItem(mnBar, SWT.CASCADE);
		mnTransaksi.setText("&Transaksi");
		menuTransaksi = new Menu(shell, SWT.DROP_DOWN);
		mnTransaksi.setMenu(menuTransaksi);
		mnPencucian = new MenuItem(menuTransaksi, SWT.PUSH);
		mnPencucian.setText("Pencucian");
		
		mnLaporan = new MenuItem(mnBar, SWT.CASCADE);
		mnLaporan.setText("&Laporan");
		
		shell.setMenuBar(mnBar);
	}

}
